<template>
    <el-button v-show="!info.bool" :icon="Plus" plain type="primary" @click="addClick"/>
    <DialogGoods/>
</template>

<script lang='ts' setup>
import { Plus } from '@element-plus/icons-vue'
import { onUnmounted, ref } from 'vue'
import DialogGoods from '@/components/Goods/dialogGoods.vue'
import { EventBus } from '@/utils/mitt'
import { useStaff } from '@/store'
import { storeToRefs } from 'pinia'

const Staff = useStaff()
const { info } = storeToRefs(Staff)
const dialogVisible = ref<boolean>(false)
const addClick = () => {
  dialogVisible.value = true
  EventBus.emit('addGoods', { bool: dialogVisible.value })
}
// 销毁当前页面的事件总线
onUnmounted(() => {
  EventBus.off('addGoods')
})
</script>

<style lang='scss' scoped>
.form {
  padding: 0 20px;
}

.span {
  display: flex;
  justify-content: space-evenly;
}
</style>